﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace KzwgRoomTester
{
    public class TaskManager
    {
        private static List<Task> taskList = new List<Task>();


        public static void AddTask(Action action, int millisecondsDelay)
        {

            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (millisecondsDelay < 0)
            {
                throw new ArgumentNullException("millisecondsDelay");
            }

            taskList.Add(Task.Run(async () =>
            {
                for (;;)
                {
                    action.Invoke();
                    await Task.Delay(millisecondsDelay);
                }
            }));
        }




        public static int TaskCount()
        {
            return taskList.Count;
        }
    }
}
